/**
*      author: Y_Yao
*      created: 2025-03-25 15:09:28
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
string s;
int q;

void solve()
{
    cin >> s;
    cin >> q;
    string left,right;
    int flag = 0;
    
    while(q--)
    {
        int T;
        cin >> T;
        if(T == 1)
        {
            flag ^= 1;
        }
        else
        {
            int f;
            string c;
            cin >> f >> c;
            if(f == 1)
            {
                if(!flag)
                {
                    c += s;
                    s = c;                
                }
                else
                {
                    s += c;
                    s = s + c;
                }
            }
            else
            {
                if(!flag)
                {
                    s += c;
                }
                else
                {
                    c += s;
                    s = c;
                }
            }
        }
    }
    if(flag % 2 != 0)
    {
        for(register int i = s.size() - 1;i >= 0;i--)
        {
            cout << s[i];
        }
        return;
    }
    cout << s << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}